<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function getRow(index) {
        // console.log(index);
        if (index === 0) return [1]
        if (index === 1) return [1, 1]
        let arr = [[1], [1, 1]]
        for (let i = 2; i <= index; i++) {
          for (let j = 0; j <= i; j++) {
            if (j === 0) {
              arr.push([1])
            } else if (j === i) {
              arr[i].push(1)
            } else {
              arr[i].push(arr[i - 1][j] + arr[i - 1][j - 1])
            }
          }
        }
        return arr[index]
      }
      console.log(getRow(3))
    </script>
  </body>
</html>
